package cn.ly.core.thread.pool;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class MyCallable implements Callable<String> {

	@Override
	public String call() throws Exception {
		System.out.println("this is MyCallable call()...");
		return "call() is called complete";
	}
	
	public static void main(String[] args) {
		ExecutorService tpool = Executors.newFixedThreadPool(2);
		
		Future<String> f =  tpool.submit(new MyCallable());
		try {
			String result = f.get();
			System.out.println(result);//这样可以得到
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		tpool.shutdown();
		
		
	}

}
